$(document).ready(function() {
	$('.role-table .this-row').live('click', function() {
		$(this).siblings().toggleClass("thisRow", ! $(this).hasClass('thisRow'));
		$(this).siblings().children('input').attr('disabled', $(this).hasClass('thisRow'));
	});
	
	$('.role-table td').live('click', function() {
		$(this).children('input').attr('disabled', $(this).hasClass('thisRow'));
		$(this).toggleClass("thisRow");
	});
	
	$('.check').live('click', function() {
		var checkedStatus = this.checked;
		$(this).parents('div[class=whead]').next('.role-table').find('td').toggleClass("thisRow", this.checked);
		$(this).parents('div[class=whead]').next('.role-table').find('td').children('input').attr('disabled', ! this.checked);
	});
	
	//预览
	$('.preview_role').click(function () {
		var url = $(this).attr('href');
		$.get(url, function (res) {
			$('#TheDialog').html(res);
			$('#TheDialog').dialog('open');
		});
		return false;
    });
	
	$('.edit_role').click(function () {
		var url = $(this).attr('href');
		$.get(url, function (res) {
			$('#TheDialog').html(res);
			$('#TheDialog').dialog('open');
		});
		return false;
    });
	
	//列表页搜索框
	if ($('form').is('#search_form')) {
		$('form#search_form .srch').click(function() {
			$(this).parents('form').submit();
		});
	}
});